<template>
  <div>
    <home-header :city="city"/>
    <home-swiper :dataList="swiperList"/>
    <home-icons :dataList="iconList"/>
    <home-hot :dataList="hotList"/>
    <home-recom :dataList="recomList"/>
    <home-weekend :dataList="weekendList"/>
  </div>
</template>

<script>
import HomeHeader from './components/Header'
import HomeSwiper from './components/Swiper'
import HomeIcons from './components/Icons'
import HomeHot from './components/Hot'
import HomeRecom from './components/Recom'
import HomeWeekend from './components/Weekend'
import axios from 'axios'
export default {
  name: 'Home',
  components: {
    HomeHeader,
    HomeSwiper,
    HomeIcons,
    HomeHot,
    HomeRecom,
    HomeWeekend
  },
  data () {
    return {
      city: '',
      swiperList: [],
      iconList: [],
      hotList: [],
      recomList: [],
      weekendList: []
    }
  },
  mounted () {
    this.getData()
  },
  methods: {
    getData () {
      axios.get('api/home.json')
        .then(this.response)
    },
    response (res) {
      res = res.data
      if (res.ret && res.data) {
        const respData = res.data
        this.city = respData.city
        this.swiperList = respData.swiperList
        this.iconList = respData.iconList
        this.hotList = respData.hotList
        this.recomList = respData.recomList
        this.weekendList = respData.weekendList
      } else {
        console.error('首页数据请求失败！')
      }
    }
  }
}
</script>

<style>
</style>
